#include<bits/stdc++.h>
#define endl '\n'
#define debug(x) cerr<<#x<<':'<<x<<endl
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int T;
int a,b;
int solve(int a,int b){
    if(!a||!b) return 0;
    if((a<0&&b<0)||(a>0&&b>0)) return 0;
    return min(abs(a+b),min(abs(a),abs(b)));
}
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
    IOS;
    cin>>T;
    while(T--){
        cin>>a>>b;
        cout<<solve(a,b)<<endl;
    }
    return 0;
}
/*
2 7
2 1

2 7
2 1
-10 -3
-10 3

10
4 -5
2 -5
7 -10
2 7
-10 -3
2 -10
-2 -10
0 -3
-7 -4
1 -2
*/